package fhp.hlhj.giantfold.customView

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.widget.LinearLayout
import android.widget.PopupWindow
import fhp.hlhj.giantfold.R
import fhp.hlhj.giantfold.interfaces.TakePhotoInterface
import kotlinx.android.synthetic.main.icon_pop.view.*

/**
 * author: FHP
 * data: on 2017\11\22 0022 11:44
 * E-Mail: 103945089@qq.com
 */
class IconPopup(private var context: Context,private var takePhotoInterface: TakePhotoInterface) :PopupWindow() {
    init {
        initPop()
    }
    private lateinit var view:View
    private fun initPop() {
        view=LayoutInflater.from(context).inflate(R.layout.icon_pop,null)
        contentView=view
        setPop()
    }

    private fun setPop() {
        this.width=LinearLayout.LayoutParams.MATCH_PARENT
        this.height=LinearLayout.LayoutParams.WRAP_CONTENT
        this.animationStyle=R.style.take_photo_anim
        this.isFocusable=true
        this.isOutsideTouchable=false
        initListener()
    }

    private fun initListener() {
        view.btCancel.setOnClickListener {
            dismiss()
        }
        view.btTakePhoto.setOnClickListener {
            takePhotoInterface.takePhoto()
        }
        view.btPickPhoto.setOnClickListener{
            takePhotoInterface.pickPhoto()
        }
    }
}